
export const ColumnWidthMixin = {
    data() {
        return {

        }
    },
    methods: {
        calcMaktxWidth(records, columns, columnsDataIndexs) {
            columns.forEach(c => {
                if (columnsDataIndexs.indexOf(c.dataIndex) > -1) {
                    let width = "120px"
                    if (records && records.length > 0) {
                        let strLen = c.title.length
                        for (let record of records) {
                            if (record[c.dataIndex] && record[c.dataIndex].length > strLen) {
                                strLen = record[c.dataIndex].length
                            }
                        }
                        if (strLen != 0) {
                            var charSize = 16
                            if (c.dataIndex == "maktx") {
                                charSize = 12
                            }
                            console.info("strLen=" + strLen)
                            console.info("charSize=" + charSize)
                            strLen = strLen * charSize
                            width = strLen + 'px'
                            if (width < c.width) {
                                width = c.width
                            }
                        }
                    } else {
                        width = '120px'
                    }
                    console.info(c.dataIndex + "width=" + width)
                    c.width = width
                }

            })
            console.info(columns)
            return columns;
        },
    }
}